import { reactive, onMounted, onBeforeUnmount } from 'vue';

const operatePoint = () => {
  const point = reactive({
    x: 0,
    y: 0
  });

  // 方法
  const savePoint = event => {
    point.x = event.pageX;
    point.y = event.pageY;
  };

  onMounted(() => {
    window.addEventListener('click', savePoint);
  });
  onBeforeUnmount(() => {
    window.removeEventListener('click', savePoint);
  });

  return point;
};

export { operatePoint };
